From 0a79eb02acc1041704b26a0b1483cb8e4574c22b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jonas=20=C3=85dahl?= Date: Sat, 18 Apr 2020 22:33:52 +0200 Subject: [PATCH] surface: Hide chained autohiding popups together When we autohide a popup surface with a grab, hide all other auto hiding popups up the popup chain. The end result is that when you click outside a menu with submenus open, the whole menu chain is dismissed. --- gdk/gdksurface.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c index 9f26ff828d..6c8195523b 100644 --- a/gdk/gdksurface.c +++ b/gdk/gdksurface.c @@ -2783,6 +2783,18 @@ gdk_synthesize_surface_state (GdkSurface *surface, gdk_surface_set_state (surface, (surface->state | set_flags) & ~unset_flags); } +static void +hide_popup_chain (GdkSurface *surface) +{ + GdkSurface *parent; + + gdk_surface_hide (surface); + + parent = surface->parent; + if (parent->autohide) + hide_popup_chain (parent); +} + static gboolean check_autohide (GdkEvent *event) { @@ -2812,7 +2824,7 @@ check_autohide (GdkEvent *event) if (grab_surface != gdk_event_get_surface (event) && grab_surface->autohide) { - gdk_surface_hide (grab_surface); + hide_popup_chain (grab_surface); return TRUE; } } -- 2.30.2